<template>
    <view>
		<view style="background-color: white;height: 170rpx;background-image: linear-gradient(to top right, #a30000, #5500ff);border-radius: 15rpx;">
			<view style="overflow: auto;">
				<view class="zhanghao" style="margin-left: 16rpx;display: flex;">
				   <view style="margin-top: 16rpx;display: flex;justify-content: center;">
					   <image v-if="isMember == 1" src="/static/iconfont/huaiyuan.png" style="width: 38rpx;height: 38rpx; "></image>
					   <image v-if="isMember == 0" src="/static/iconfont/shixiao.png" style="width: 38rpx;height: 38rpx; "></image>
					   <text style="font-weight: bold;margin-left: 20rpx;color: white;">账号：{{username}}({{uid}})</text>
				   </view>
							 
				</view>
			</view>
			<view style="margin-left: 16rpx;display: flex;margin-top: 16rpx;">
				<image  src="/static/iconfont/ye.png" style="width: 38rpx;height: 38rpx; "></image>
			   <text style="font-weight: bold;;margin-left: 20rpx;color: white;">余额￥{{userAmt}}.00</text>
			</view>
			<view style="margin-left: 16rpx;">
				<text v-if="isMember == 1" style="font-size: 25rpx; color: #bfbfbf;">会员到期时间：{{memberEndTimeString}}</text>
				<text v-if="isMember == 0" style="font-size: 25rpx; color: #bfbfbf;">暂未获得会员权限(会员可查看所有讲师课件)</text>
			</view>
			
		</view>
		
<!-- 
		<view style="background-color: white; border-radius: 16rpx;overflow: auto;margin-top:16rpx ;">

		
		   <view class="lecturer">
			<view class="caozuo">
				<image  style="width: 70rpx; height: 70rpx;" @tap="appfor" src="/static/iconfont/kaitonghuiyuan.png"></image>
				<text v-if="isMember == 1">续费会员</text>
				<text v-if="isMember == 0">开通会员</text>
			</view>
			
			<view class="caozuo">
				<image  style="width: 70rpx; height: 70rpx;" @tap="addAmt" src="/static/iconfont/chongzhi.png"></image>
				<text>余额充值</text>
			</view>
			
			<view class="caozuo">
				<image  style="width: 70rpx; height: 70rpx;" @tap="toOrderFrom" src="/static/iconfont/dingdan.png"></image>
				<text>我的订单</text>
			</view>
			
			
		
			
		   </view>
		   <view class="lecturer2">
			   <view class="caozuo"  >
			   	<image  style="width: 70rpx; height: 70rpx;" @tap="toAbout" src="/static/iconfont/guanyu.png"></image>
			   	<text>关于我们</text>
			   </view>
			
			   <view class="caozuo"  >
			   	<image  style="width: 70rpx; height: 70rpx;" @tap="resetpassword" src="/static/iconfont/resetpassword.png"></image>
			   	<text>重置密码</text>
			   </view>
			  
			   <view class="caozuo" >
			   	<image  style="width: 70rpx; height: 70rpx;" @tap="toLogin" src="/static/iconfont/tuichu.png"></image>
			   	<text>退出登录</text>
			   </view>			   
		   </view>
		</view> -->
		
		<view style="display: flex;justify-content: space-between;margin-top: 10rpx;">
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #a30000, #00f);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image  style="width: 70rpx; height: 70rpx;" @tap="appfor" src="/static/iconfont/kaitonghuiyuan.png"></image>
					<text style="color: white;margin-top: 10rpx;" v-if="isMember == 1">续费会员</text>
					<text style="color: white;margin-top: 10rpx;"v-if="isMember == 0">开通会员</text>
				</view>
			</view>
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #005500, #aa00ff);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image  style="width: 70rpx; height: 70rpx;" @tap="addAmt" src="/static/iconfont/chongzhi.png"></image>
					<text style="color: white;margin-top: 10rpx;">余额充值</text>
				</view>
			</view>
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #005500, #55aa7f);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image  style="width: 70rpx; height: 70rpx;" @tap="toOrderFrom" src="/static/iconfont/dingdan.png"></image>
					<text style="color: white;margin-top: 10rpx;">我的订单</text>
				</view>
			</view>
		</view>
		<view style="display: flex;justify-content: space-between;margin-top: 10rpx;">
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #214283, #537328);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
				<image  style="width: 70rpx; height: 70rpx;" @tap="toAbout" src="/static/iconfont/guanyu.png"></image>
				<text style="color: white;margin-top: 10rpx;">关于我们</text>
				</view>
			</view>
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #505050, #aa0000);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image  style="width: 70rpx; height: 70rpx;" @tap="resetpassword" src="/static/iconfont/resetpassword.png"></image>
					<text style="color: white;margin-top: 10rpx;">重置密码</text>
				</view>
			</view>
			<view style="padding:50rpx;background-image: linear-gradient(to top right, #555500, #aa00ff);border-radius: 15rpx;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image  style="width: 70rpx; height: 70rpx;" @tap="toLogin" src="/static/iconfont/tuichu.png"></image>
					<text style="color: white;margin-top: 10rpx;">退出登录</text>
				</view>
			</view>
		</view>
		
		
		
		
    </view>
</template>

<script>
const app = getApp();
var urlPrefix = app.globalData.urlPrefix;
export default {
    data() {
        return {
            height: '',
			memberEndTimeString:'',
            //屏幕高度
            imageUrl: null,
			isMember:0,
            nicknamenickname: '',
            gender: 0,
            uid: 0,
            type: 0,
            username: '',
            viewingRecords: [],
            inputName: '',
			
			isDialogShow: false,
			inputValue: '',
			userAmt:0,
			token:null
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {
        var userId = uni.getStorageSync('userId');
		var token = uni.getStorageSync('token');
		this.token = token;
        let that = this;
        if (userId) {
            uni.request({
                url: urlPrefix + '/api/applet/myInfo/myInfo?userId=' + userId,
                method: 'GET',
                header: {
                    'content-type': 'application/json',
                     'token': this.token
                },
                success: function (res) {
                    let dataList = res.data;
                    if (dataList.resp_code == 0) {
                        that.setData({
                            //imageUrl: dataList.datas.headImgUrl,
                            username: dataList.datas.username,
                            uid: dataList.datas.id,
							userAmt:dataList.datas.amt,
							isMember:dataList.datas.isMember,
							memberEndTimeString:dataList.datas.memberEndTimeString
                        });
                    }
                }
            });
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        let that = this;
        var userId = uni.getStorageSync('userId');
        if (userId) {
            uni.request({
                url: urlPrefix + '/api/applet/myInfo/myInfo?userId=' + userId,
                method: 'GET',
                header: {
                    'content-type': 'application/json',
                    'token': this.token
                },
                success: function (res) {
                    let dataList = res.data;
                    if (dataList.resp_code == 0) {
                        that.setData({
                            nickname: dataList.datas.nickname,
                            uid: dataList.datas.id,
							userAmt:dataList.datas.amt,
							isMember:dataList.datas.isMember,
							memberEndTimeString:dataList.datas.memberEndTimeString
                        });
                    }
                }
            });
        }
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() { // 停止下拉刷新
			let that = this;
			var userId = uni.getStorageSync('userId');
			if (userId) {
				uni.request({
					url: urlPrefix + '/api/applet/myInfo/myInfo?userId=' + userId,
					method: 'GET',
					header: {
						'content-type': 'application/json',
						 'token': this.token
					},
					success: function (res) {
						let dataList = res.data;
						if (dataList.resp_code == 0) {
							that.setData({
								//imageUrl: dataList.datas.headImgUrl,
								username: dataList.datas.username,
								uid: dataList.datas.id,
								type: dataList.datas.isType,
								userAmt:dataList.datas.amt,
								isMember:dataList.datas.isMember
							});
						}
					}
				});
			}
	
		uni.stopPullDownRefresh();  //停止刷新
		uni.showToast({
			title: '刷新成功',
			icon: 'none',
			duration: 2000
		});
	},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    onShareTimeline(res) {
        // 分享到朋友圈
        return {};
    },
    methods: {
		addAmt(){
			uni.navigateTo({
				url: "/pages/recharge/recharge",
			})
		},
		appfor(){
		
			uni.navigateTo({
				url: "/pages/applyFor/applyFor?isMember="+this.isMember,
			})
			
				
		},
		toAbout(){
		  uni.navigateTo({
		  	url: "/pages/about/about",
		  })
		},

		
		toLogin(){
			
		
			uni.showModal({
			    title: '操作提示',
			    content: '是否退出登录?',
			    success(res) {
			        if (res.confirm) {
						uni.removeStorageSync("token");
						uni.reLaunch({
							url: "/pages/login/login",
						})
			        } else if (res.cancel) {
			            //这里是点击取消执行事件
			        }
			    }
			});
		},
		
		toOrderFrom(){
		  var userId = uni.getStorageSync('userId');
		if (userId) {
		    uni.navigateTo({
		        url: '/pages/orderFrom/orderFrom?userId=' + userId
		    });
		}
		},
		

		resetpassword : function (res) {
		    var username = uni.getStorageSync('username');
		    if (username) {
		        uni.navigateTo({
		            url: '/pages/resetpassword/resetpassword?username=' + username
		        });
		    }
		},
    }
};
</script>
<style lang="scss">
@import './myinfo.scss';
</style>
